﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using MachiningHelper.ToolFile;

namespace Skipper_Connector
{
    public class Config
    {
        private static XMLHelper xml = new XMLHelper(Application.StartupPath + "\\Config.xml");

        public static string InPort
        {
            get { return xml.getXmlValue("BasicSet", "trsPort"); }
            set { xml.setXmlValue("BasicSet", "trsPort", value); }
        }
        public static string OutPort
        {
            get { return xml.getXmlValue("BasicSet", "recPort"); }
            set { xml.setXmlValue("BasicSet", "recPort", value); }
        }
        public static string MachinePath
        {
            get { return xml.getXmlValue("BasicSet", "machinePath"); }
            set { xml.setXmlValue("BasicSet", "machinePath", value); }
        }
        public static string CodePath
        {
            get { return xml.getXmlValue("BasicSet", "codePath"); }
            set { xml.setXmlValue("BasicSet", "codePath", value); }
        }
        public static bool PortState
        {
            get { return bool.Parse(xml.getXmlValue("BasicSet", "PortState")); }
            set { xml.setXmlValue("BasicSet", "PortState", value.ToString()); }
        }
        public static int ModeState
        {
            get { return int.Parse(xml.getXmlValue("BasicSet", "modeState")); }
            set { xml.setXmlValue("BasicSet", "modeState", value.ToString()); }
        }
        public static string Toolfile
        {
            get { return xml.getXmlValue("BasicSet", "toolfile"); }
            set { xml.setXmlValue("BasicSet", "toolfile", value); }
        }
        public static string NPAN
        {
            get { return xml.getXmlValue("BasicSet", "NPAN"); }
            set { xml.setXmlValue("BasicSet", "NPAN", value); }
        }
        public static string OutputCsv
        {
            get { return xml.getXmlValue("BasicSet", "OutputCsv"); }
            set { xml.setXmlValue("BasicSet", "OutputCsv", value); }
        }
        public static string PMOD
        {
            get { return xml.getXmlValue("BasicSet", "PMOD"); }
            set { xml.setXmlValue("BasicSet", "PMOD", value); }
        }
        public static bool IsMachiningTransform
        {
            get { return bool.Parse(xml.getXmlValue("BasicSet", "IsMachiningTransform")); }
            set { xml.setXmlValue("BasicSet", "IsMachiningTransform", value.ToString()); }
        }
        public static string FileExtension
        {
            get
            {
                return ColToolFile.LoadToolFile(Config.CurrentToolFile).FileExtension;
            }
        }
        public static string CurrentToolFile
        {
            get { return xml.getXmlValue("BasicSet", "CurrentToolFile"); }
            set { xml.setXmlValue("BasicSet", "CurrentToolFile", value); }
        }
        public static string LastToolFile
        {
            get { return xml.getXmlValue("BasicSet", "LastToolFile"); }
            set { xml.setXmlValue("BasicSet", "LastToolFile", value); }
        }

        public static bool NormalMachine
        {
            get { return Properties.Settings.Default.NormalMachine; }
            set
            {
                Properties.Settings.Default.NormalMachine = value;
                Properties.Settings.Default.Save();
            }
        }
        public static bool OpenCheckRepeat
        {
            get { return Properties.Settings.Default.OpenChekRepeat; }
            set
            {
                Properties.Settings.Default.OpenChekRepeat = value;
                Properties.Settings.Default.Save();
            }
        }
        public static string DataPath
        {
            get { return Properties.Settings.Default.DataPath; }
            set
            {
                Properties.Settings.Default.DataPath = value;
                Properties.Settings.Default.Save();
            }
        }
        public static string FlagChar
        {
            get { return Properties.Settings.Default.FlagChar; }
            set
            {
                Properties.Settings.Default.FlagChar = value;
                Properties.Settings.Default.Save();
            }
        }
        public static int JobNameIndex
        {
            get { return Properties.Settings.Default.JobNameIndex; }
            set
            {
                Properties.Settings.Default.JobNameIndex = value;
                Properties.Settings.Default.Save();
            }
        }
        public static int CodeNameIndex
        {
            get { return Properties.Settings.Default.CodeNameIndex; }
            set
            {
                Properties.Settings.Default.CodeNameIndex = value;
                Properties.Settings.Default.Save();
            }
        }
        public static bool IsChangeBarcode
        {
            get { return Properties.Settings.Default.IsChangeBarcode; }
            set
            {
                Properties.Settings.Default.IsChangeBarcode = value;
                Properties.Settings.Default.Save();
            }
        }
        public static bool TestMode
        {
            get { return Properties.Settings.Default.TestMode; }
            set
            {
                Properties.Settings.Default.TestMode = value;
                Properties.Settings.Default.Save();
            }
        }
    }
}